
////////////////////////////////////////////////////////////////////////////////
//
// XMLReader.java
//
// Copyright © (C) 2010
// 
// Emory Hughes Merryman, III
// emory.merryman@gmail.com
// 
// All Rights Reserved
// 
// This file is part of Interworks.
// 
// Interworks is free software: you can 
// redistribute it and/or modify it under 
// the terms of the GNU General Public 
// License as published by the Free 
// Software Foundation, either version 3 
// of the License, or (at your option) any 
// later version.
// 
// This program is distributed in the hope 
// that it will be useful, but WITHOUT 
// ANY WARRANTY; without even the 
// implied warranty of MERCHANTABILITY 
// or FITNESS FOR A PARTICULAR 
// PURPOSE.  See the GNU General Public 
// License for more details.
//
// You should have received a copy of the 
// GNU General Public License along with 
// this program.  If not, see 
// <http://www.gnu.org/licenses/>.
////////////////////////////////////////////////////////////////////////////////

package
    com . superiorglobalbusiness . cB7zEmeT ;

import java.io.File;
import java.io.IOException;
import org.jdom.Document;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

/**
 * Reads a given String filename and returns the org.jdom.Document
 * object representing the XML file. The given filename must be
 * a valid XML file otherwise an exception will be thrown.
 */
public class XMLReader {
    public static Document getXMLFile ( final java . lang . String filename ) throws IOException , JDOMException {
	File f = new File(filename);
	Document document = null;
	if (f != null) {
	    if (!f.isFile()) {
		throw new IOException(
				      "In XMLReader.getXMLFile, the given String filename does NOT name a file."
				      );
	    } else {
		SAXBuilder parser = new SAXBuilder();
		document = parser.build(f);
		return document;
	    }
	}
	return null;
    }
}
